﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using CashFlow.ShopManage.Models.User;
using CashFlow.ShopManage.Common;

namespace CashFlow.ShopManage.Validator.User
{
    public class UserInfoQueryParamModelValidator
        : AbstractValidator<UserInfoQueryParamModel>
    {
        public UserInfoQueryParamModelValidator()
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(x => x.State).Must(x =>
            {
                if (x.HasValue)
                {
                    if (x == 0 || x == 1)
                    {
                        return true;
                    }
                    return false;
                }
                else
                {
                    return true;
                }
            }).WithMessage("State格式不正确！");
        }
    }
}